package java_io.autoclose;

import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;

public class ReadFile {
public static void main(String[] args) {
		
		try(FileInputStream input = new FileInputStream("file.txt")) {

			int data = input.read();
			while(data != -1){
				System.out.print((char) data);
				data = input.read();
			}
		}catch(FileNotFoundException ex){
			System.out.println(ex.toString());
		}catch(IOException ex){
			System.out.println(ex.toString());
		}
	}
}
